<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <!-- 1、引入依赖 -->
  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

  <div id="app"></div>

  <!-- 2、编写react代码 -->
  <script type="text/babel">
    function getSizeImage(imgUrl, size) {
      return imgUrl + `?param=${size}y${size}`
    }

    class App extends React.Component {
      constructor(){
        super()
        this.state = {
          title: '标题',
          imgUrl: 'https://p2.music.126.net/UDpjFEHmXInxGd_xMAI12w==/109951162811986419.jpg',
          link: 'http://www.baidu.com',
          active: true
        }

      }


      // 所有组件必须实现render方法
      render() {
        const { title, imgUrl, link, active } = this.state


        // 必须用return返回
        return (
          // {}语法  里面可以是表达式
          <div>
            {/* 1、绑定普通属性*/}
           <h2 title={title}>我是标题</h2>
           <img src={getSizeImage(imgUrl, 140)} alt="" />
           <a href={link}>百度一下</a>

           {/* 2、绑定class*/}
           <div className='element title'>div元素</div>
           <div className={'element title ' + (active ? 'active' : '')}>div元素</div>
           
           {/* 3、绑定style  
            {}外层--表示里面放js代码   
            {}里面--放一个对象  对象中属性名由多个单词组成时使用驼峰写法
          */}
           <div style={{color: 'pink', fontSize: '20px'}}>绑定style</div>
           <label htmlFor=""></label>
          </div>
        )
      }
    }


    ReactDOM.render(<App/>, document.getElementById('app')) 
  </script>
</body>
</html>